module PrismBreak {

    export class View {
        private frameworkApp: PbApp;

        public Id: string;
        public ViewModel: any;
        public Node: HTMLElement;

        constructor(frameworkApp: PbApp, id?: string, vm?: any, node?: HTMLElement) {
            this.frameworkApp = frameworkApp;
            this.Id = id;
            this.ViewModel = vm;
            this.Node = node;
        }


        public Deactivate(): View {

            var jnode = $(this.Node);

            jnode.removeClass(PrismBreak.ViewClass[PrismBreak.ViewClass.pb_visible]);

            if (!jnode.hasClass(PrismBreak.ViewClass[PrismBreak.ViewClass.pb_invisible])) {
                jnode.addClass(PrismBreak.ViewClass[PrismBreak.ViewClass.pb_invisible]);
            }

            return this;

        }

        public Activate(): View {
            var jnode = $(this.Node);

            jnode.removeClass(PrismBreak.ViewClass[PrismBreak.ViewClass.pb_invisible]);

            if (!jnode.hasClass(PrismBreak.ViewClass[PrismBreak.ViewClass.pb_visible])) {
                jnode.addClass(PrismBreak.ViewClass[PrismBreak.ViewClass.pb_visible]);
            }

            this.frameworkApp.EventManager.Publish(PrismBreak.EventType.ViewActivated, this);


            return this;
        }
    }
}